import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.utils import get_openapi
from fastapi.staticfiles import StaticFiles
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html

from controller.DataPreController import router as custom_router
from controller.DrawController import router as draw_router
from controller.ConclusionController import router as conclusion_router
from controller.PassCheckController import router as pass_router
from controller.CableStrainController import router as strain_router
from controller.DescentDepthController import router as descent_router
from controller.SafeCableController import router as safe_router
from controller.WellStabilityController import router as stability_router
from controller.PiercController import router as pierc_router
app = FastAPI()
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)
# app.include_router(alg_router)
app.include_router(custom_router)
app.include_router(draw_router)
app.include_router(conclusion_router)
app.include_router(pass_router)
app.include_router(strain_router)
app.include_router(descent_router)
app.include_router(safe_router)
app.include_router(stability_router)
app.include_router(pierc_router)

app.mount("/static", StaticFiles(directory="static"), name="static")


@app.get("/docs", include_in_schema=False)
async def docs():
    return get_swagger_ui_html(openapi_url="/openapi.json", title="API Docs")


@app.get("/redoc", include_in_schema=False)
async def redoc():
    return get_redoc_html(openapi_url="/openapi.json", title="API Docs")


@app.get("/openapi.json", include_in_schema=False)
async def openapi():
    return get_openapi(title="API Docs", version="1.0.0", description="API documentation")


@app.get("/")
async def root():
    return {"message": "Hello World"}


if __name__ == '__main__':
    uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=False)
